package org.gpp.proj1.robot.action.executor;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import junit.framework.TestCase;

import org.easymock.EasyMock;
import org.gpp.proj1.bone.Bone;
import org.gpp.proj1.robot.Robot;
import org.gpp.proj1.robot.action.PartAction;
import org.gpp.proj1.robot.action.step.ActionStep;
import org.gpp.proj1.robot.modifier.Modifier;
import org.gpp.proj1.robot.part.EquippedPart;
import org.gpp.proj1.robot.part.PartType;
import org.gpp.proj1.robot.part.emissor.Emissor;

/**
 * Tests for the action executor class
 * 
 * @author Paolo Victor, paolovictor@gmail.com
 */
public class ActionExecutorTest extends TestCase {
	public void testExecuteAction() {
		Robot robotMock = EasyMock.createMock( Robot.class );
		EquippedPart part = new EquippedPart( "testPart",
				PartType.HEAD,
				100,
				new HashMap<String, Integer>(),
				new LinkedList<Modifier>(),
				new HashMap<String, String>(),
				new HashMap<String, String>(),
				new LinkedList<Emissor>(),
				new LinkedList<String>(),
				robotMock,
				new HashMap<String, Bone>() );		
		
		ActionStep stepMock = EasyMock.createMock( ActionStep.class );
		
		List<ActionStep> steps = new LinkedList<ActionStep>();
		for( int k = 0; k < 5; k++ ) {
			steps.add( stepMock );
		}
		
		PartAction action = new PartAction( "Action", steps );
		
		ActionExecutor executor = new ActionExecutor( part, action );
		
		EasyMock.reset( stepMock );
		stepMock.execute( part, null ); EasyMock.expectLastCall().times( 5 ) ;
		EasyMock.replay( stepMock );
		
		executor.run();
		
		EasyMock.verify( stepMock );
	}
}
